﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MsTestUtilities;
using MsTestUtilities.Utilities;

namespace MsTestUtilitiesTests.Utilities.RequireTests
{
    [TestClass]
    public class MultipleUnnamedArgumentNotNullTests
    {
        [TestMethod]
        public void ArgumentIsNull_FailWithRightArgument()
        {
            ExAssert.Throws<ArgumentNullException>(
                () => TestDifferentArgumentTypes(null, string.Empty),
                e => e.ParamName == "myArgument");
        }

        [TestMethod]
        public void OtherIsNull_Pass()
        {
            TestDifferentArgumentTypes(string.Empty, null);            
        }

        [TestMethod]
        public void MultipleArguemntsOfSameType_ParamNameUnknown()
        {
            ExAssert.Throws<ArgumentNullException>(
                () => TestSameArgumentTypes(null, "something"),
                e => e.ParamName == "Unknown");
        }

        [TestMethod]
        public void MultipleArguemntsOfSameType_MessageListsCandidates()
        {
            ExAssert.Throws<ArgumentNullException>(
                () => TestSameArgumentTypes(null, "something"),
                e => e.Message.Contains("Candidates are <myArgument, other>"));
        }

        private void TestDifferentArgumentTypes(string myArgument, object other)
        {
            Require.ArgumentNotNull(myArgument);
        }

        private void TestSameArgumentTypes(string myArgument, string other)
        {
            Require.ArgumentNotNull(myArgument);
        }
    }
}
